package service

import (
	"trace-rule/internal/domain/model"
	"trace-rule/internal/repository"
)

type RuleService struct {
	repo *repository.RuleRepository
}

func NewRuleService(repo *repository.RuleRepository) *RuleService {
	return &RuleService{repo: repo}
}

func (s *RuleService) CreateRule(rule *model.Rule) error {
	return s.repo.Create(rule)
}

func (s *RuleService) UpdateRule(rule *model.Rule) error {
	return s.repo.Update(rule)
}

func (s *RuleService) DeleteRule(id uint) error {
	return s.repo.Delete(id)
}

func (s *RuleService) GetRule(id uint) (*model.Rule, error) {
	return s.repo.FindByID(id)
}

func (s *RuleService) ListRules(page, pageSize int) ([]model.Rule, int64, error) {
	return s.repo.List(page, pageSize)
}

func (s *RuleService) ListEnabledRules() ([]model.Rule, error) {
	return s.repo.ListEnabled()
}
